package com.eqs.enterprisequestionnaire.controller;

import com.eqs.enterprisequestionnaire.result.R;
import com.eqs.enterprisequestionnaire.service.LevelQuestionAnalysisService;
import com.eqs.enterprisequestionnaire.service.SortQuestionAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/levelQuestionAnalysis")
public class LevelQuestionAnalysisController {
    @Autowired
    private LevelQuestionAnalysisService levelQuestionAnalysisService;

    @GetMapping("/levelAverageScore/{questionId}")
    public R<Double> getLevelAverageScore(@PathVariable Integer questionId){
        Double averageScore = levelQuestionAnalysisService.getAverageScore(questionId);
        return  R.success(averageScore);
    }
    @GetMapping("/levelRankings/{questionId}")
    public R<Map<Integer, Double>> getLevelRankingProportions(@PathVariable Integer questionId) {
        Map<Integer, Double> levelProportions = levelQuestionAnalysisService.getLevelRankingProportions(questionId);
        return R.success(levelProportions);
}
}